package com.ruoyi.project.file.controller;


import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.file.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("file")
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传图片
     */
    @PostMapping(value = "/uploadObjectOSS",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public AjaxResult uploadObjectOSS(@RequestPart MultipartFile file) throws IOException {
        return ossService.upload(file);
    }

    /**
     * 上传图片
     */
    @PostMapping(value = "/uploadObjectOSSs",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public AjaxResult uploadObjectOSSs(@RequestPart MultipartFile[] file) throws IOException {
        return ossService.upload(file);
    }
}
